﻿using PermissionManager.Model;
using PermissionsManager.BLL;
using PermissionsManager.DAL;
using System;
using System.Collections.Generic;
using System.Linq;

namespace PermissionManager.BLL
{
    public class LogsService : BaseService<Logs>
    {
        LogsRepository repository = new LogsRepository();

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="journal"></param>
   
        public List<Logs> QueryList(string name, DateTime time)
        {
            return repository.QueryList(l => l.JName == name || l.CreateTime == time);
        }

        public List<LogsBase> QueryLogsAll()
        {
            using (var db = new PermissionManagerEntities())
            {
                var str = from a in db.Logs
                          join b in db.AdminUserRole
                          on a.AdminUserId equals b.AdminUserId
                          join c in db.Role
                          on b.RoleId equals c.Id
                          select new LogsBase()
                          {
                              AdminUserId = a.AdminUserId,
                              JName = a.JName,
                              Name = c.Name,
                              Content = a.Content,
                              CreateTime =a.CreateTime
                          };
                return str.ToList();
            
            }
                

            
        }
    }
}
